package com.specter.utils;

import java.io.IOException;
import java.util.Properties;

import lombok.extern.slf4j.Slf4j;

/**
 * Note:读取spring配置中的properties文件
 * 
 * @author Liang.Wang
 * @version Dec 27, 2016
 */
@Slf4j
public abstract class PropsUtils {

	private static Properties props;

	private PropsUtils() {
	}

	public static void init() {
		if (props == null) {
			props = new Properties();
			try {
				log.debug("load properties from application.properties !");
				props.load(PropsUtils.class.getClassLoader().getResourceAsStream("application.properties"));
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

	public static String getValue(String name) {
		init();
		return props.getProperty(name);
	}

}
